package com.douqu.game.main.service;

import com.douqu.game.core.database.model.ServerModel;
import com.douqu.game.core.factory.WorldInfoFactory;
import com.douqu.game.main.database.mapper.read.ReadServerMapper;
import com.douqu.game.main.database.mapper.write.WriteServerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by bean on 2017/8/12.
 */
@Service
public class WorldServiceImpl implements WorldService {

    @Autowired
    private ReadServerMapper readServerMapper;

    @Autowired
    private WriteServerMapper writeServerMapper;

    @Override
    public void create(ServerModel serverModel) {
        writeServerMapper.create(serverModel);
    }

    @Override
    public ServerModel find() {
        return readServerMapper.find();
    }

    @Override
    public void update()
    {
        ServerModel serverModel = WorldInfoFactory.getInstance().save();
        if(serverModel == null)
            return;

        writeServerMapper.update(serverModel);
    }


}
